package cn.wolfcode.web.controller;

import cn.wolfcode.domain.SysDictType;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.ISysDictTypeService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;


/**
 * ClassName SysDictTypeController
 * Create by Mike
 * Date 2021/8/1 16:52
 */
@Controller
@RequestMapping("/sysDictType")
public class SysDictTypeController {

    @Autowired
    private ISysDictTypeService sysDictTypeService;

    @RequestMapping("/list")
    public String list(Model model, QueryObject qo){
        PageInfo<SysDictType> pageInfo = sysDictTypeService.query(qo);
        model.addAttribute("pageInfo",pageInfo);
        return "/sysDictType/list";
    }

    @RequestMapping("/saveOrUpdate")
    public String saveOrUpdate(SysDictType sysDictType){
        if (sysDictType.getId() == null){
            sysDictTypeService.save(sysDictType);
        }else {
            sysDictTypeService.update(sysDictType);
        }
        return "redirect:/sysDictType/list";
    }

    @RequestMapping("/input")
    public String input(Long id,Model model){
        if (id != null) {
            model.addAttribute("sysDictType",sysDictTypeService.get(id));
        }
       return "/sysDictType/input";
    }

}
